package part_2;

public class GasPump {
	
	private double maxGas = 15000;			// max storable gas in the tank in liter
	private double gasInTank = 10000;		// gas in the tanck at the moment in liter
	private boolean isRegular = true;		// the type of gas Regualer/Super
	private double gasPrice = 1.1;			// Speaks for itself euro/l
	
	
	public GasPump() {
		
	}
	
	public GasPump(double gasInTank,boolean isReguar, double price) {
		this.gasInTank = gasInTank;
		this.isRegular = isReguar;
		this.gasPrice = price;
	}
	
	//processes a request for a pump action
	public void requestGas(double request) {
		System.out.println("Requesting " + request + " l gas");
		if(request <= gasInTank) {
			//enough gas
			pumpGas(request);
		} else {
			//NOT ENOUGH gas
			pumpGas(gasInTank);
		}
		System.out.println();
	}
	
	//Actualy pomps the gas
	private void pumpGas(double amount) {
		System.out.print("<pre:" + gasInTank + " out:"+ amount);
		gasInTank -= amount;
		System.out.println(" post:" + gasInTank + " price:" + gasPrice * amount + " >");
	}
	
	// Refills the gas tank
	public void refill() {
		gasInTank = maxGas;
		System.out.println("Gastank refilled to " + gasInTank);
	}
	
	//Tests equality of two GasPumps
	public void equals(GasPump pump) {
		if ((this.gasPrice == pump.gasPrice) && (this.isRegular && pump.isRegular)) {
			System.out.println("The given pumps were identical");
		} else {
			System.out.println("The pumps are non identical");
		}
		this.status();
		pump.status();
		System.out.println();
	}
	
	// Shows the status of two gaspumps
	public void status() {
		System.out.println("<stored:"+gasInTank+" isRegular:"+isRegular+" gasprice:"+gasPrice+">");
		
	}
	
}
